<?php
/**
 * @annotate 登陆类
 * @group   Admin/Haiyin
 * @author   mengke.yue <mengke.yue@gmail.com>
 */
class LoginAction extends BaseAction {
	public function sign_in(){
		$this->assign('Title',"人才来了后台登陆");
		$url=U('Home/index');
   	    $this->checkPost();
        $Admin = D('Login');
		$uname = getRequest('uname');
        $password = getRequest('password');
        $oUser=$Admin->getUser($uname);
      	if (empty($oUser)) {
			$this->error('对不起，用户名不存在！');
			return false;
		}
		  
		if ($oUser['pwd'] != md5(md5($password).$oUser['login_salt'])) {
			$this->error('对不起，密码不正确！');
			return false;
		}else{
			$Admin->add_logintime($oUser['aid']);
			$_SESSION['admin'] = $oUser;
			$this->assign("jumpUrl",$url);//跳转
	        $this->success("登陆成功！");	
		}
	}

	public function sign_out(){
		$Admin = D('Login');
		$url=U('Login/sign_in');
		$re = $Admin->sign_out();
		if($re){
			$this->assign("jumpUrl",$url);//跳转
			$this->success("退出成功！");		
		}
	}
}
?>